﻿using System;
using System.Data;
using DotNetNuke.Entities.Content;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Users;

namespace DotNetNuke.Modules._2DoTasks.Components.Entities
{
    public class _ProjectMember : ContentItem
    {
        public int ProjectId { get; set; }

        public int UserId { get; set; }

        public bool IsManager { get; set; }

        /// <summary>
        /// The user
        /// </summary>
        public UserInfo MemberInfo
        {
            get
            {
                return UserController.GetUserById(PortalController.GetCurrentPortalSettings().PortalId, UserId);
            }
        }

        #region IHydratable Implementation

        public override void Fill(IDataReader dr)
        {
            ProjectId = Convert.ToInt32(dr["PrjMbr_ProjectId"]);

            UserId = Convert.ToInt32(dr["PrjMbr_UserId"]);

            IsManager = Convert.ToBoolean(dr["PrjMbr_isManager"]);

            //base.FillInternal(dr);  ToDo - Implement Taxonomy
        }

        public override int KeyID
        {
            get
            {
                return UserId;
            }
            set
            {
                UserId = value;
            }
        }

        #endregion IHydratable Implementation
    }
}